/* =================================================
 * Package:			dk.iha.toksEditor
 * File:			Patient.java
 * Description:		This is the class for which is
 * 					responsible for saving and
 * 					loading patients information.
 * 
 * Responsible
 * =================================================
 * Name:			Bjarke Jensen
 * Study number:	09676
 * 
 * Assistant(s)
 * =================================================
 * Name:			Vinnie Juul
 * Study number:	09767
 */

package dk.iha.toksEditor;

import java.io.Serializable;
import java.util.Date;


public class Patient implements Serializable{
	private static final long serialVersionUID = 1L;
	private String CPR;
	private String name;
	private String note = "";
	private TOKS toks;
	private Boolean mIsChecked;
	private Boolean isFavorite = false;
	private Date lastUpdated = new Date(0);
	
	/**
	 * Contructor
	 * @param CPR - cpr for the patient
	 * @param name - name of the patient
	 */
	public Patient(String CPR, String name)
	{
		setCPR(CPR);
		setName(name);
		setIsChecked(false);
	}
	
	/**
	 * Contructor
	 * @param CPR - cpr for the patient
	 * @param name - name of the patient
	 * @param note - note for the patient
	 */
	public Patient(String CPR, String name, String note)
	{
		setCPR(CPR);
		setName(name);
		setNote(note);
		setIsChecked(false);
	}
	
	/**
	 * Get patient note
	 * @return String containing the note
	 */
	public String getNote() {
		return note;
	}

	/**
	 * Set patient note
	 * @param note - string containing the note for the patient
	 */
	public void setNote(String note) {
		this.note = note;
	}
	
	/**
	 * Get patient CPR number
	 * @return CPR-number as a sting
	 */
	public String getCPR() {
		return CPR;
	}
	
	/**
	 * Set patient CPR number
	 * @param cPR - string conaining the CPR number
	 */
	public void setCPR(String cPR) {
		CPR = cPR;
	}
	
	/**
	 * Get patient name
	 * @return string containing the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Set patient name
	 * @param _name - string containing the name
	 */
	public void setName(String _name) {
		name = _name;
	}

	/**
	 * Get patient toks
	 * @return  - TOKS containing the TOKS for the patient
	 */
	public TOKS getTOKS() {
		return toks;
	}

	/**
	 * Set patient toks
	 * @param toks - TOKS containing the toks
	 */
	public void setTOKS(TOKS toks) {
		this.toks = toks;
	}

	/**
	 * Get cpr in format XXXXXX-XXXX
	 * @return - String containing the cpr in specific format
	 */
	public String getEasyCPR(){
		 StringBuilder patientEasyCPR = new StringBuilder();
		 patientEasyCPR.append(getCPR().substring(0, 6));
		 patientEasyCPR.append('-');
		 patientEasyCPR.append(getCPR().substring(6, 10));
		 return patientEasyCPR.toString();
	}

	/**
	 * Get if the patient is on the users favorite list
	 * @return - Boolean; true if patient is favorit, false if not
	 */
	public Boolean getIsFavorite() {
		return isFavorite;
	}

	/**
	 * Set if the patient is on the users favorite list
	 * @param isFavorite - Boolean; true if the patient should be on the list, false if not
	 */
	public void setIsFavorite(Boolean isFavorite) {
		this.isFavorite = isFavorite;
	}

	/**
	 * Get if the patient has been checked
	 * This is used when removing form custom listviews
	 * @return - Boolean; true if the patient is check, false if not
	 */
	public Boolean getIsChecked(){
		return mIsChecked;
	}
	
	/**
	 * Set if the patient should be check for not
	 * @param isChecked - Boolean; true if patient should be check, false if not
	 */
	public void setIsChecked(Boolean isChecked)
	{
		mIsChecked = isChecked;
	}

	/**
	 * Get last updated time.
	 * @return Returns - the last updated time as a Date.
	 */
	public Date getLastUpdated()
	{
		return lastUpdated;
	}
	
	/**
	 * Set the time where the patient was last updated
	 * @param date - Date containing the date
	 */
	public void setLastUpdated(Date date)
	{
		lastUpdated = date;
	}
}
